﻿package com.everydayflash.pv3d.precision {
	
	import flash.display.BitmapData;
	import org.papervision3d.materials.BitmapMaterial;
	import org.papervision3d.materials.shaders.FlatShader;
	import org.papervision3d.materials.shaders.ShadedMaterial;
	import org.papervision3d.materials.utils.MaterialsList;

	/**
	 * A simple wrapper for the MaterialList from the Pixel Precision demo
	 * 
	 * Keeps track of the BitmapData objects
	 * 
	 * @author Bartek Drozdz [http://www.everydayflash.com]
	 */
	public class CubeMaterial {
		
		private var names:Array = ["back", "front", "right", "left", "top", "bottom" ];
		private var bmps:Array;
		private var list:MaterialsList;
		private var num:int = 6;
		
		public function CubeMaterial() {
			bmps = new Array();
			list = new MaterialsList();
		}
		
		public function init(width:Number, height:Number):void {
			for (var i:int = 0; i < num; i++) {
				var bmp:BitmapData = new BitmapData(width, height, false, 0xffffffff);
				var mat:BitmapMaterial = new BitmapMaterial(bmp);

				bmps.push(bmp);
				
				mat.interactive = true;
				list.addMaterial(mat, names[i]);
			}
		}
		
		public function getBitmap(matIndex:int):BitmapData {
			return bmps[matIndex] as BitmapData;
		}

		public function getList():MaterialsList {
			return list;
		}
	}
	
}